package com.simpleframe.security;

import java.util.ArrayList;
import java.util.List;

import com.simpleframe.exception.SimpleframeException;

public class Module {

	private String id;
	private String name;
	private List<Action> actions;
	
	public Module(){
		actions = new ArrayList<Action>();
	}
	
	public void addAction(Action action){
		if(existAction(action)){
			throw new SimpleframeException("扩展中已经存在功能 "+action.getId());
		}
		actions.add(action);
	}
	
	private boolean existAction(Action action){
		for (Action act : actions) {
			if(act.getId().equals(action.getId())){
				return true;
			}
		}
		return false;
	}

	public List<Action> getActions() {
		return actions;
	}
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
